This section describes how graphics import components work and briefly discusses how to write a component. If you're interesting in writing a component, you should read this section.
Format-specific graphics import components, such as the importers for JPEG, PNG, TIFF etc., are simple components. When a format-specific graphics importer is opened, it opens and targets an instance of the base importer. Subsequently, it delegates most of its calls to the base importer instance, as shown in Figure 16-3 .
Figure 3 Delegating calls to the base importer
The base importer communicates with data handler components to access image file data, and with the Image Compression Manager to arrange for image rendering. The only service a format-specific importer must provide is the GraphicsImportGetImageDescription call, which examines an image file and constructs an image description for it. The base importer uses this image description to respond to other calls such as GraphicsImportGetNaturalBounds and GraphicsImportDraw . (In the case of GraphicsImportDraw , the image description is passed to the Image Compression Manager, so the cType field must identify a codec that will be able to draw the image. If a graphics importer needs to pass extra information that the codec will need at PreDecompress time, it can pass it in an image description extension.)
Sometimes, the data to be passed to the image decompressor is only a portion of the file. In these cases, the format-specific importer should implement the GraphicsImportGetDataOffsetAndSize function to indicate the byte range to send to the image decompressor. (It is often useful for this call to first call the generic importer's implementation to find out the size of the input data stream.)
Under QuickTime 4.0, there is a 64-bit analogue of this function, called GraphicsImportGetDataOffsetAndSize64 . In order to provide compatibility with old graphics importers, the generic importer's implementation of this function calls the 32-bit version.
New format-specific importers may implement both the 32-bit and 64-bit versions if it makes sense for their file formats.
Graphics import components may override other calls, such as GraphicsImportGetMetaData , which extracts supplemental information from an image file, and GraphicsImportGetMIMETypeList , which provides information about the format.
Another optional call is GraphicsImportValidate , which attempts to ascertain quickly whether a file matches the importer's format. This is especially useful for formats which start with identifying codes or "magic numbers" (such as PNG and TIFF) in situations where image files do not have correct file types or suffixes. In situations like this, the Image Compression Manager may ask many graphics importers in turn to validate until it finds one that accepts the file, so it is important that GraphicsImportValidate calls not be too slow. Format-specific importers that implement the GraphicsImportValidate call should have the canMovieImportValidateFile bit set in their component flags.
Graphics importers supporting image formats which can have transparent regions should implement the GraphicsImportDoesDrawAllPixels call so as to warn applications that they may need to erase the destination area before drawing.
| Previous | Chapter Contents | Chapter Top | Next |